package com.hungtrung.script;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.hungtrung.entity.Ga;
import com.hungtrung.entity.GiaCam;
import com.hungtrung.entity.Ngang;
import com.hungtrung.entity.Vit;

public class HungTrungScript {
	private GiaCam giaCam;
	private ArrayList<GiaCam> listGiaCam = new ArrayList<GiaCam>();

	public void themGiaCam(SpriteBatch sb) {
		if (Gdx.input.isKeyJustPressed(Keys.G)) {// them 1 con ga
			giaCam = new Ga(new Vector2(400 - 82, 600 - 82), new Vector2(0, 0));
			listGiaCam.add(giaCam);
		}
		if (Gdx.input.isKeyJustPressed(Keys.V)) {// them 1 con vit
			giaCam = new Vit(new Vector2(400 - 82, 600 - 82), new Vector2(0, 0));
			listGiaCam.add(giaCam);
		}

		if (Gdx.input.isKeyJustPressed(Keys.N)) {// them 1 con ngang
			giaCam = new Ngang(new Vector2(400 - 82, 600 - 82), new Vector2(0,
					0));
			listGiaCam.add(giaCam);
		}

		if (!listGiaCam.isEmpty()) {
			for (int i = 0; i < listGiaCam.size(); i++) { // cap nhat vi tri, render len man hinh cho tat ca cac con gia cam moi them
				listGiaCam.get(i).render(sb);
				listGiaCam.get(i).update();

			}
		}
	}

}
